﻿$(function() {
	var optbarchart = echarts.init(document.getElementById('optbarchart'));
	var optbaroption = {
	    tooltip: {
	        trigger: 'axis',
	        axisPointer: {
	            type: 'shadow'
	        }
	    },
	    legend: {
	        data: ['优化前', '优化后']
	    },
	    backgroundColor:'#e0e0e0',
	    grid: {
            top: '18%',
            left: '3%',
            right: '3%',
            bottom:'5%',
            containLabel: true
        },
	    xAxis: {
	    	type: 'category',
	        data: ['工艺时间','工艺能耗','有效运行率(%)','能耗利用率(%)']
	    },
	    yAxis: {
	        type: 'value',
	        boundaryGap: [0, 0.01]
	    },
	    series: [{
            name: '优化前',
            type: 'bar',
            data: [58, 300, 28, 21],
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        position: 'top'
                    }
                }
            }
        },{
            name: '优化后',
            type: 'bar',
            data: [47, 276, 37, 27],
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        position: 'top'
                    }
                }
            }
        }]
	};
	optbarchart.setOption(optbaroption);
	
	$.post(basePath+'/engrgyoptimi/power.json',function(data){
		var d = new Array();
		var p1 = new Array();
		var p2 = new Array();
		var p3 = new Array();
		$.each(data,function(index,e){
			d.push(e.time);
			p1.push(e.power_total1);
			p2.push(e.power_total2);
			p3.push(e.power_total3);
		});
		var optlinechart = echarts.init(document.getElementById('optlinechart'));
		var optlineoption = {
		    tooltip: {
		        trigger: 'axis',
		        axisPointer: {
		            type: 'shadow'
		        }
		    },
		    legend: {
		        data:['PowerA','PowerB','PowerC']
		    },
		    backgroundColor:'#e0e0e0',
		    grid: {
	            top: '15%',
	            left: '3%',
	            right: '3%',
	            bottom:'5%',
	            containLabel: true
	        },
		    xAxis: {
		        type: 'category',
		        boundaryGap: false,
		        data: d
		    },
		    yAxis: {
		        type: 'value'
		    },
		    series: [{
	            name:'PowerA',
	            type:'line',
	            data:p1
	        },{
	            name:'PowerB',
	            type:'line',
	            data:p2
	        },{
	            name:'PowerC',
	            type:'line',
	            data:p3
	        }]
		};
		optlinechart.setOption(optlineoption);
	});
	
    $('#opt_data').datagrid({    
	    url: basePath+"/resources/json/opt.json",
	    method: 'get',
	    striped : true,
		nowrap : true,
		rownumbers : true,
		singleSelect : true,
		fitColumns : true,
		border:false,
		scrollbarSize:1,
	    columns:[[
			{field:'datatime',align:'center','title':'yc',width:100},
			{field:'data',align:'center','title':'fz',width:100},
			{field:'power',align:'center','title':'ap',width:100},
			{field:'speed',align:'center','title':'ae',width:100},
			{field:'feed',align:'center','title':'工艺时间',width:150},
			{field:'deep',align:'center','title':'运行率',width:150},
			{field:'wd',align:'center','title':'工艺能耗',width:150},
			{field:'diameter',align:'center','title':'能量利用率',width:150}
	    ]]
	});
});